new Vue({
    el: "#mainContent",
    data: {
        name: "",
        cardList: [],
        getCardList: "/card/get_card_list.ajax",
        detailUrl: "/card/detail",
        addCardUrl: "/card/add",
        cardIndexUrl: "/card/index"
    },
    mounted: function () {
        this.name = $("#nameUser").val();
        this.initPage();
    },
    methods: {
        //初始化页面
        initPage: function () {
            this.$http.get(this.getCardList)
                .then((response) => {
                    this.$set(this, "cardList", response.data.data);
                })
                .catch(function (response) {
                    console.log(response)
                });
        },
        jumpToDetail: function (event, card) {
            window.location.href = this.detailUrl + "?cardId=" + card.cardId;
        },
        login: function () {
            layer.open({
                type: 2,
                title: '',
                fix: false,
                maxmin: true,
                shadeClose: true,
                area: ['400px', '300px'],
                content: '/login/login',
            });
        },
        register: function () {
            layer.open({
                type: 2,
                title: '',
                fix: false,
                area: ['400px', '300px'],
                content: '/login/login',
            });
        },
        jumpToAddCard: function () {
            window.location.href = this.addCardUrl;
        },
        jumpToCard: function () {
            window.location.href = this.cardIndexUrl;
        }
    }
});